<template>
  <div>
    <div class="adminset">

      <div class="adminsetin">
      <el-form ref="form" :model="form" label-width="80px">
  <el-form-item label="修改密码">
    <el-input type="password" v-model="form.pwd"></el-input>
  </el-form-item>
  <span ref="sp" style="color:red;margin:85px"></span>
  <el-form-item label="确认密码">
    <el-input type="password" v-model="form.pwd1"></el-input>
  </el-form-item>
  </el-form>
   <el-button class="btn" type="primary" @click="adminpwd()" round>提交修改</el-button>
  </div>

    <div id="code"></div>


    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        form:{
          pwd:"",
          pwd1:""
        }
      }
    },
    methods:{
      adminpwd(){
        if(this.form.pwd==""){
          alert("修改密码不能为空")
          return
        }
        if(this.form.pwd===this.form.pwd1){
          this.axios.get(`/user/loginadminup?admin_pwd=${this.form.pwd}&admin_user=${sessionStorage.getItem("admin")}`).then((res)=>{
            if (res.data.code==200){
              alert('密码修改成功请重新登录')
              this.esc();
            }
          });
        }else{
          this.$refs.sp.innerText="两次秘密不一致请核查从新输入"
          this.form.pwd=""
          this.form.pwd1=""
        }
      },
      

    esc(){
        sessionStorage.removeItem("admin")
        this.$router.push("/admin")
      },
    },



    mounted:function(){
        
    }
    
  }
</script>




<style scoped>
.adminset{
  width: 500px;
  height: 300px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}
.adminsetin{
  width: 100%;
   position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}

.btn{
  margin: 0 180px;
  width: 200px;
}
</style>